#include "LOG.h"


LOG::LOG(void)
{
	out.open("log.txt");
}


LOG::~LOG(void)
{
}
const string LOG::currentDateTime(bool client)
{
	time_t now=time(0);
	struct tm tstruct;
	char buf[80];
	tstruct = *localtime(&now);
	if(client)
	{
		strftime(buf, sizeof(buf),"%a %d %Y %X GMT : client :",&tstruct);
	}
	else
	{
		strftime(buf, sizeof(buf),"%a %d %Y %X GMT : server :",&tstruct);
	}
	
	return buf;
}
	
void LOG::logLine(const string message, bool client)
{
	string ourMessage(currentDateTime(client));
	out << ourMessage + message << endl;
	cout << ourMessage + message << endl;
}

void LOG::close()
{
	out.close();
}